<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Start</title>
	</head>
	<body>
		Loading...
		<script type="text/javascript">
			var fs = require('fs');
			var d = new Date();
			var datetime = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + 
				d.getHours() + ";" + d.getMinutes() + ";" + d.getSeconds() + ";" + d.getMilliseconds();
			var datetime_file_name = datetime + '.json';
			var file_index = 1;
			while (fs.existsSync('archives/' + datetime_file_name)) {
				datetime_file_name = datetime + '_' + file_index + '.json';
				++file_index;
			}
			var db_json = {
				day: 1,
				packages: [],
				plots: -1,
				local: '',
				record: [],
			};
			var current_json = {
				target: datetime_file_name,
			};
			fs.writeFileSync('archives/' + datetime_file_name, JSON.stringify(db_json));
			fs.writeFileSync('current.json', JSON.stringify(current_json));
			location.href = 'bedroom.html';
		</script>
	</body>
</html>
